package com.tian.jobhandler;

import com.tian.service.PromptUserCouponExpiredService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * {@code @description:} TODO
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-08-27 21:26
 * {@code @version:} 1.0
 */
@Slf4j
@Component
public class PromptUserCouponExpiredJobHandler {

    @Resource
    private PromptUserCouponExpiredService promptUserCouponExpiredService;

    @Transactional
    @XxlJob("promptUserCouponExpiredJobHandler")
    public void process() {
        log.info("开始执行优惠券过期提醒任务");
        try {
            promptUserCouponExpiredService.doPrompt();
        } catch (Exception e) {
            log.error("执行优惠券过期提醒任务失败", e);
        }
        log.info("结束执行优惠券过期提醒任务");
    }
}
